/**
 * 如何修改属性值
 */
import React from 'react'

class App extends React.Component {
  // 数据声明
  state = {
    count: 0,
    value: '' // 输入框值
  }
  // count++
  addCount = () => {
    this.setState({
      count: this.state.count + 1
    })
  }

  changeValue = (e) => {
    this.setState({
      value: e.target.value
    })
  }

  render () {
    return (
      <>
        <div>这是一个计数器：{this.state.count}</div>
        <button onClick={this.addCount}>数据+1</button>
        <br />
        <input value={this.state.value} onChange={this.changeValue} />
        <div>{this.state.value}</div>
      </>
    )
  }
}

export default App